using System;
using System.Collections.Generic;
using System.Security.Cryptography;
using System.Text;
using System.Data;

using PlugNT.Safe;
using PlugNT.Cms.Custom;
using PlugNT.Database;
using PlugNT.Database.Common.Simple;
using PlugNT.App.UCenter.Model;

namespace PlugNT.App.UCenter.BLL
{
    public class UMessage
    {
        private static readonly PlugNT.App.UCenter.DAL.UMessage dal = new PlugNT.App.UCenter.DAL.UMessage();


        public UMessageInfo GetUMessageInfo(int id)
        {
            return dal.GetUMessageInfo(id);
        }

        public bool Add(UMessageInfo info)
        {
            return dal.Add(info);
        }

        public bool Delete(int sysModelId,string andWhere)
        {
            return dal.Delete(sysModelId, andWhere);
        }











        public DataTable GetList(int sysModelId, int pageSize, int currPage, int userId, out int recordCount)
        {
            StringBuilder andwhere = new StringBuilder();
            if (userId > 0)
            {
                andwhere.Append(" and [user_id]=" + userId.ToString());
            }
            recordCount = dal.GetCount(sysModelId,andwhere.ToString());
            return dal.GetList(sysModelId, pageSize, currPage, andwhere.ToString());
        }










        public DataTable GetJoinList(int sysModelId, int pageSize, int currPage, int userId, out int recordCount)
        {
            LeftJoinInfo joininfo = new LeftJoinInfo(WebConfig.UsersTableName, "username,email", "user_id", WebConfig.GetUserField("id"), "");
            recordCount = dal.GetCount(sysModelId, " and [user_id]=" + userId.ToString());
            return dal.GetList(sysModelId, pageSize, currPage," and [user_id]=" + userId.ToString(), joininfo);
        }


     





    }
}

